<%-- Created by IntelliJ IDEA. --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>add Cookie</title>
  </head>
  <body>
  <h2>【Apple苹果】欢迎您访问！</h2>

  <%
      //1.生成序列信息
      String info ;
      String strinfo = null;
      if(application.getAttribute("info")==null)
          application.setAttribute("info","苹果");
      else{
          strinfo =application.getAttribute("info").toString() + "-苹果";
          application.setAttribute("info",strinfo);
      }

//      out.println("字符=" + application.getAttribute("info").toString() );

      //2.设置Cookie
      Cookie ck1 = new Cookie("name",java.net.URLEncoder.encode( application.getAttribute("info").toString() ,"gbk"));
      ck1.setMaxAge(360); //set timer s
      response.addCookie(ck1);  //ADD COOKIE


  %>

  </body>
</html>